//商品列表弹出菜单
$('.nav-left').children('.pop').mouseenter(function() {
		var $this = $(this);
		$this.children('.collapse').addClass('open');
		$('.nav').addClass('active');
	}).mouseleave(function() {
		var $this = $(this);
		$this.children('.collapse').removeClass('open');
		$('.nav').removeClass('active');
	})
	//注册及购物车弹出菜单
$('.nav-right').children('li').mouseenter(function() {
	var $this = $(this);
	$this.children('.collapse').addClass('open');
	$('.nav').addClass('active');
}).mouseleave(function() {
	var $this = $(this);
	$this.children('.collapse').removeClass('open');
	$('.nav').removeClass('active');
})

var slider = {
	clone: null,
	i: 0,
	size: null,
	timer: null,
	TIME: 8000,
	init: function() {
		this.clone = $('.slider-box li').first().clone();
		$('.slider-box').append(this.clone);
		this.size = $('.slider-box li').size();
		this.autoP();
		this.mouse();
	},
	//右移动一页
	moveR: function() {
		this.i++;
		if(this.i == this.size) {
			$('.slider-box').css({
				left: 0
			});
			this.i = 1;
		}
		$('.slider-box').stop().animate({
			left: '-' + this.i + '00%'
		}, 400);
		if(this.i == this.size - 1) {
			$('.slider-num li').eq(0).addClass('on').siblings().removeClass('on');
		} else {
			$('.slider-num li').eq(this.i).addClass('on').siblings().removeClass('on');
		}
	},
	//自动播放
	autoP: function() {
		this.timer = setInterval(this.moveR.bind(this), this.TIME);
	},
	//清除定时器
	clearT: function() {
		clearInterval(this.timer);
	},
	//鼠标点击圆点
	mouse: function() {
		$('.slider-num li').click(function(e) {
			this.clearT();
			var $target = $(e.target);
			this.i = $target.index();
			$('.slider-box').stop().animate({
				left: '-' + this.i + '00%'
			}, 400);
			$target.addClass('on').siblings().removeClass('on');
			this.autoP();
		}.bind(this))
	}

}
slider.init();